Home
Knowledge Areas
SQL (General)
About SQL Server
General
My favorite SSMS Options
SQL Versions
Admin Tasks
General
Auditing - script to create an auditing table
Backing up SQL Express
Backup Database Tutorial (2008)
Backup Database Tutorial (2014)
Backup one database and restore to another in a script
BULK INSERT
Create a table on a linked server
Creating SSIS Packages from Visual Studio 2019
Decrypt a Stored Procedure
How to change the DB Collation for a Dynamics GP server
Logins - Drop multiple logins from all databases
Recovery Model for each Database on a Server (FULL or SIMPLE)
Restore Database Tutorial (2008)
Restore Database Tutorial (2014)
Run a script against all databases
Run a script against all Dynamics GP company databases
Turn off SQL Compression
Monitoring SQL
Run DBCC CHECKTABLE against all the tables in a database
SQL Maintenance Queries
Truncate a SQL Log File
SQL 2008 +
Truncate all Log Files in a Dataase
SQL 2008 +
Beautifying T-SQL Code
Code that writes code
These are TSQL scripts that write other types of scripts. The are used to write TSQL and .NET code
Code Gen
Form with a grid and Export button
Script to create a Table from Stored Procedure parameters
Write the code for a VB edit grid form
Helper Functions/Views
ddf_ColumnNameVB
ddf_ColumnType
ddf_columnTypeVB
DDReservedWords
ddv_DALTableColumnMetaData
Functions that create Telerik columns
Configuring Email
Common errors when setting up email alerts
Setting up database mail on SQL 2008 R2
Setting up DB mail
sp_send_dbmail
Function Library
ddf_AddBusinessDays
ddf_Address
ddf_ClearNumericCharacters - Remove numeric characters from a string
ddf_FormatNumeric - formats a dollar value
ddf_FormattedQty - Formatted Quantities using DECPLQTY
ddf_GetLastDayOfMonth
ddf_PadRight
ddf_Phone
ddf_RegexReplace - Regex Replace function for SQL
Programming tasks
Calling a web service from SQL
Case sensitive SQL queries
Comma Separated Output
Comma separated detail from a sub table
ddf_PopPosOnAContract (comma separated list of children)
Definitive! Comma separated values in a query
Parse a comma separated string into a SQL table 1
Parse a comma separated string into a SQL table 2
STRING_AGG SQL 2017 (14) or later
Connection String Example
Copy ANY TABLE from one database to another
Create (and restore a database to) a TEST server for app testing
Creating a date calendar table
Date Functions
FORMAT date examples (SQL 2012 and later)
Get the first day of the week from a week number
Find table and field a particular value reside
Find tables that have no permissions granted, and fix them
Get a person's age from their birthdate
Get the text of all the triggers in a database
Group by Grouping Sets example
How to format T-SQL
Insert an image into a SQL table from SQL
Log the user that changed a field
Loop through a string and show ASCII characters
Paging query contest
Parsing @tags from a SQL text field
Query that adds a blank like to the result set if the original resultset has more than one line
Remove unwanted characters from a field in SQL
sp_send_dbmail example
SQL code to resequence a grid
SQL Trigger Nest Level
Strip leading zeros
Suppress the results of a stored procedure
Table Value Constructors
Templates
Dynamic INSERT statement
Function - SCALAR
Function - table valued
Stored Procedure
Trigger
TRY/CATCH
View
Writing To A Text File
Write all DB contents to a text file SQL 2012
Puzzler
SQL Puzzler 2/13/2019
SQL Puzzler 3/8/2019
SQL XML
T-SQL
Calculate Business Days
CHARINDEX/PATINDEX
Copy ALL the data from one database to another
CROSS APPLY example
CTE Example
CTE Example showing multiple sources, ddv_401k
CTE Example showing Recursion
dd_FL
DELETE into an OUTPUT table
EXCEPT in SQL triggers for Dynamics GP
FORMAT - examples of date formatting
FORMAT - Format a number
FORMAT - Format a number as a percent
FORMATMESSAGE (SQL equivalent to String.Format)
Margin Calculations
RAISERROR - formatting the error string
ROW_NUMBER()
Return the first row in a child table with multiple rows
Sum fields that are in group rows - a custom RUNNING TOTAL excercise
Running Sum
SELECT Statement
SQL Bulk Insert
SQL Pivot code
SQL Stuff
Unit Testing T-SQL Code
RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences